import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutterapp/src/page/play/video_detail_widget.dart';
import 'package:flutterapp/src/utils/log_utils.dart';

class ListItemWidget extends StatefulWidget {
  final bool isScroll;
  final StreamController streamController;
  ListItemWidget({this.streamController, this.isScroll = false});
  @override
  _ListItemWidgetState createState() => _ListItemWidgetState();
}

class _ListItemWidgetState extends State<ListItemWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 2),
      padding: EdgeInsets.all(10),
      color: Colors.white,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          //  视频标题 +头像
          buildTitle(),
          SizedBox(height: 10),
          // 视频层
          Container(
            height: 220,
            child: buildVideoWidget(),
          )
        ],
      ),
    );
  }

  Widget buildTitle() {
    return Row(
      children: [
        Icon(Icons.one_k),
        Text("GGB flutter 探险之路"),
      ],
    );
  }

  Widget buildVideoWidget() {
    if (widget.isScroll) {
      return Container(
        width: MediaQuery.of(context).size.width,
        child: Image.asset(
          "assets/images/welcome.png",
          fit: BoxFit.fitWidth,
        ),
      );
    }
    return VideoDetailWidget(
      streamController: widget.streamController,
    );
  }
}
